import emojiList from "@/config/emoji.js";

export const useContent = (props) => {
    const isExpand = ref(false);

    const renderList = computed(() => {
        if (props.list.length > 2) {
            return isExpand.value ? props.list : props.list.slice(0, 2);
        } else {
            return props.list;
        }
    });

    const formatComment = (commentStr) => {
        for (let emoji of emojiList) {
            const reg = new RegExp(`\\[${emoji}\\]`, "g");
            commentStr = commentStr.replace(
                reg,
                `<img emoji-icon src='${_oss_}images/emoji/${emoji}.gif' />`
            );
        }
        return commentStr;
    };

    return { renderList, isExpand, formatComment };
};
